home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261c.zoo / objects / BinaryTree.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  2.1 KB  |  76 lines

  1. /* Interface for Objective-C BinaryTree collection object
  2.    Copyright (C) 1993,1994 Free Software Foundation, Inc.
  3.  
  4.    Written by:  R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
  5.    Date: May 1993
  6.  
  7.    This file is part of the GNU Objective C Class Library.
  8.  
  9.    This library is free software; you can redistribute it and/or
  10.    modify it under the terms of the GNU Library General Public
  11.    License as published by the Free Software Foundation; either
  12.    version 2 of the License, or (at your option) any later version.
  13.    
  14.    This library is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.    Library General Public License for more details.
  18.  
  19.    You should have received a copy of the GNU Library General Public
  20.    License along with this library; if not, write to the Free
  21.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */ 
  23.  
  24. /* 
  25.    Binary Tree.  
  26.    Base class for smarter binary trees.
  27. */
  28.  
  29. #ifndef __BinaryTree_h_INCLUDE_GNU
  30. #define __BinaryTree_h_INCLUDE_GNU
  31.  
  32. #include <objects/stdobjects.h>
  33. #include <objects/IndexedCollection.h>
  34.  
  35. /* The <BinaryTreeComprising> protocol defines the interface to an object
  36.    that may be an element in a BinaryTree. 
  37. */
  38. @protocol BinaryTreeComprising
  39. - leftNode;
  40. - rightNode;
  41. - parentNode;
  42. - setLeftNode: (id <BinaryTreeComprising>)aNode;
  43. - setRightNode: (id <BinaryTreeComprising>)aNode;
  44. - setParentNode: (id <BinaryTreeComprising>)aNode;
  45. @end
  46.  
  47. #define NODE_IS_RIGHTCHILD(NODE) (NODE == [[NODE parentNode] rightNode])
  48. #define NODE_IS_LEFTCHILD(NODE) (NODE == [[NODE parentNode] leftNode])
  49.  
  50. @interface BinaryTree : IndexedCollection
  51. {
  52.   unsigned int _count;
  53.   id _contents_root;
  54. }
  55.  
  56. - nilNode;
  57. - rootNode;
  58.  
  59. - leftmostNodeFromNode: aNode;
  60. - rightmostNodeFromNode: aNode;
  61.  
  62. - (unsigned) depthOfNode: aNode;
  63. - (unsigned) heightOfNode: aNode;
  64.  
  65. - (unsigned) nodeCountUnderNode: aNode;
  66.  
  67. - leftRotateAroundNode: aNode;
  68. - rightRotateAroundNode: aNode;
  69.  
  70. - binaryTreePrintForDebugger;
  71.  
  72. @end
  73.  
  74.  
  75. #endif /* __BinaryTree_h_INCLUDE_GNU */
  76.